package com.example.zzm.yuejian03.Activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.example.zzm.yuejian03.Adapter.CollectclubAdapter;
import com.example.zzm.yuejian03.Adapter.collectmAdapter;
import com.example.zzm.yuejian03.Bean.CollectclubBean;
import com.example.zzm.yuejian03.Bean.CollectmBean;
import com.example.zzm.yuejian03.Bean.collectBean;
import com.example.zzm.yuejian03.Listener.ClubcollectListrener;
import com.example.zzm.yuejian03.Listener.CollectmListrener;
import com.example.zzm.yuejian03.Listener.TListener;
import com.example.zzm.yuejian03.Model.ClubcollectModel;
import com.example.zzm.yuejian03.Model.CollectclubModel;
import com.example.zzm.yuejian03.Model.CollectmModel;
import com.example.zzm.yuejian03.Model.MyModel;
import com.example.zzm.yuejian03.R;

import java.util.List;

public class GuanzhuActivity extends AppCompatActivity {

    private TextView textView11;
    private Button button22,button23,button26;
    private RecyclerView recyclerView;
    private int userid;
    private SharedPreferences sp;

    public void  onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.guanzhu);
        initView();
        initEvent();
        initDate();
        sp = getSharedPreferences("userInfo",MODE_PRIVATE);

        userid=sp.getInt("user_id",1);
        ClubcollectModel myModel = new ClubcollectModel();
        myModel.getClubcollectList(userid,listener);
//        CollectclubModel model = new CollectclubModel();
//        model.unLike(userid,tlistener);
    }

    ClubcollectListrener listener = new ClubcollectListrener() {
        @Override
        public void onResponse(List<CollectclubBean> beanlist) {
            CollectclubAdapter classAdapter = new CollectclubAdapter(getApplicationContext(),beanlist);
            recyclerView.setAdapter(classAdapter);
        }

        @Override
        public void onFail(String msg) {
        }
    };
    CollectmListrener tlistener = new CollectmListrener() {
        @Override
        public void onResponse(List<CollectmBean> beanlist) {
            collectmAdapter classAdapter = new collectmAdapter(getApplicationContext(),beanlist);
            recyclerView.setAdapter(classAdapter);
        }

        @Override
        public void onFail(String msg) {
        }
    };

    private void initDate() {

    }

    private void initEvent() {
        textView11.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        button23.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                CollectmModel myModel = new CollectmModel();
                myModel.getmcollectList(userid,tlistener);
            }
        });
        button22.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ClubcollectModel myModel = new ClubcollectModel();
                myModel.getClubcollectList(userid,listener);
            }
        });
    }

    private void initView() {
        textView11 = (TextView)findViewById(R.id.textView11);
        button22 = (Button)findViewById(R.id.button22);
        button23 = (Button)findViewById(R.id.button23);
        recyclerView = (RecyclerView)findViewById(R.id.recyclerview);
        LinearLayoutManager layoutManager = new LinearLayoutManager(this.getApplicationContext());
        layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
        recyclerView.setLayoutManager(layoutManager);
    }
}

